<?php
/**
 * RSS Feed for blog
 *
 * @author Chris Lunsford
 */
class Feed extends Controller {
	
	/**
	 * Class constructor
	 */
	function __construct() {
		parent::__construct();
		
		$this->load->helper('xml');	
	}
	
	function blog() {
        $data['encoding'] = 'utf-8';
        $data['feed_name'] = 'xa-ncsu.com blog';
        $data['feed_url'] = 'http://www.xa-ncsu.com';
        $data['page_description'] = 'The discussion blog for the Chi Alpha group at NC State and Meredith College.';
        $data['page_language'] = 'en-us';
        $data['creator_email'] = 'Email webmaster at xa-ncsu dot com';
		$this->load->model('BlogModel');
        $posts = $this->BlogModel->getRecentPosts();
		foreach ($posts->result() as $row) {
			$row->description = substr(strip_tags(html_entity_decode($row->body)),0,200);
		}
		$data['posts'] = $posts;
        header("Content-Type: text/xml");
        $this->load->view('feed/blog', $data);
    }
	
	function podcasts() {
        $data['encoding'] = 'utf-8';
        $data['feed_name'] = 'xa-ncsu.com podcasts';
        $data['feed_url'] = 'http://www.xa-ncsu.com';
        $data['page_description'] = 'The weekly podcasts from the Chi Alpha group at NC State and Meredith College.';
        $data['page_language'] = 'en-us';
        $data['creator_email'] = 'Email webmaster at xa-ncsu dot com';
		$this->load->model('ContentModel');
 		$data['podcasts'] = $this->ContentModel->getPodcasts();
 
        header("Content-Type: text/xml");
        $this->load->view('feed/podcasts', $data);
    }
	
	function announcements() {
        $data['encoding'] = 'utf-8';
        $data['feed_name'] = 'xa-ncsu.com news';
        $data['feed_url'] = 'http://www.xa-ncsu.com';
        $data['page_description'] = 'The announcements from the Chi Alpha group at NC State and Meredith College.';
        $data['page_language'] = 'en-us';
        $data['creator_email'] = 'Email webmaster at xa-ncsu dot com';
		$this->load->model('ContentModel');
 		$data['announcements'] = $this->ContentModel->getCurrentAnnouncements();
 
        header("Content-Type: text/xml");
        $this->load->view('feed/announcements', $data);
    }
}
?>